using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Backend.JYD.AModel.Models.Mapping
{
    public class TaskStepModelConditionMap : EntityTypeConfiguration<TaskStepModelCondition>
    {
        public TaskStepModelConditionMap()
        {
            // Primary Key
            this.HasKey(t => new { t.StepPropertyId, t.TaskModeId, t.StepId, t.IsLastRequired, t.IsNextRequired, t.IsLoopRequired });

            // Properties
            this.Property(t => t.StepPropertyId)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.TaskModeId)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.StepId)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.TableName)
                .HasMaxLength(20);

            this.Property(t => t.FieldName)
                .HasMaxLength(20);

            this.Property(t => t.ConditionValue)
                .HasMaxLength(100);

            // Table & Column Mappings
            this.ToTable("TaskStepModelCondition");
            this.Property(t => t.StepPropertyId).HasColumnName("StepPropertyId");
            this.Property(t => t.TaskModeId).HasColumnName("TaskModeId");
            this.Property(t => t.StepId).HasColumnName("StepId");
            this.Property(t => t.IsLastRequired).HasColumnName("IsLastRequired");
            this.Property(t => t.IsNextRequired).HasColumnName("IsNextRequired");
            this.Property(t => t.IsLoopRequired).HasColumnName("IsLoopRequired");
            this.Property(t => t.TableName).HasColumnName("TableName");
            this.Property(t => t.FieldName).HasColumnName("FieldName");
            this.Property(t => t.ConditionType).HasColumnName("ConditionType");
            this.Property(t => t.ConditionValue).HasColumnName("ConditionValue");
            this.Property(t => t.Type).HasColumnName("Type");
            this.Property(t => t.Status).HasColumnName("Status");
            this.Property(t => t.CreateTime).HasColumnName("CreateTime");
            this.Property(t => t.UpdateTime).HasColumnName("UpdateTime");
            this.Property(t => t.OpId).HasColumnName("OpId");
        }
    }
}
